package com.aaa.controller;


import com.aaa.entity.ZcglPrivate;
import com.aaa.service.ZcglPrivatelandService;
import com.aaa.util.Result;
import com.baomidou.mybatisplus.extension.api.ApiController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ZcglPrivateland)表控制层
 *
 * @author makejava
 * @since 2021-01-30 14:15:55
 */
@RestController
@RequestMapping("/private")
public class ZcglPrivatelandController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private ZcglPrivatelandService service;

    /**
     * create by: Student洋
     * description: 测试后端是否与数据库连接成功
     */
    @RequestMapping("/aaa")
    public Result listAll(){ return service.listAll(); }


    /**
     * create by: Student洋
     * description: 根据资产编号进行单条记录的详细查询
     */
    @RequestMapping("/one")
    public Result Select(String assetNumber) {
        List<ZcglPrivate> list = service.selectOne(assetNumber);
        return new Result(1005,"详情展示 ",list) ;
    }
    /**
     * create by: Student洋
     * description: 逻辑删除
     */

    @RequestMapping("/del")
    public Result delete(String assetNumber) {
        boolean del = service.delete(assetNumber);
        if (del){
            return new Result(1005,"删除成功 ",null) ;
        }
        return new Result(1005,"删除失败 ",null) ;
    }
    /**
     * create by: Student洋
     * description: 添加操作 双表，同时往两个表里添加数据
     */
    @RequestMapping("/add")
    public Result add(@RequestBody ZcglPrivate add){
        int a = service.addPrivate(add);
        int b = service.addHouse(add);
        if (a != 0 & b !=0 ){
            return new Result(1023,"添加成功",null);
        }
        return new Result(1023,"添加失败",null);
    }
    /**
     * create by: Student洋
     * description: 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody ZcglPrivate update){
        int a = service.updatePrivate(update);
        int b = service.updateHouse(update);
        if (a != 0 & b !=0 ){
            return new Result(1023,"修改成功",null);
        }
        return new Result(1023,"修改失败",null);
    }




}